package xml;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;

/**
 * @author Thomas Wangler, wangler_thomas@hotmail.com
 * Translation Memories for patent translation
 * OutputXML
 * Tests whether CreateXML computes the right values.
 */

public class OutputXML {

	/**
	 * Main-Method for the class CreateXML
	 * Tests whether CreateXML computes the right values.
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {

		try{
			String file = args[0];
			File outfile = new File(args[1]);

			
			FileInputStream dataStream = null;
			dataStream = new FileInputStream(file);
		
			BufferedReader datareader = new BufferedReader(new InputStreamReader(dataStream, "UTF8"));
		
		
			FileOutputStream oStream = null;
			oStream = new FileOutputStream(outfile);
			Writer outWriter = new BufferedWriter(new OutputStreamWriter(oStream, "UTF8"));
		
		
			String line = datareader.readLine();
		
			while(line != null){
			
				try{
					CreateXML curr_xml = new CreateXML(line);
					outWriter.write(curr_xml.getTranslation()+"\n");
				}catch(Exception e){
					System.out.println("Error");
					e.printStackTrace();
				}
				line = datareader.readLine();
			
			}
		
			datareader.close();
			outWriter.close();
		
		}catch(IOException e){
			e.printStackTrace();
		}
	}

}
